package com.wyiot.pet.mapper;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wyiot.pet.model.vo.AddressVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wyiot.pet.model.entity.AddressDO;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AddressMapper extends BaseMapper<AddressDO> {
    /**根据用户id查询此用户的所有地址信息*/
    @Select("select  address_user_name , address_phone_number , address_city , address_detail , address_isdefault from user_address where address_user_id = #{addressUserId} order by address_isdefault DESC")
    Page<AddressVO> selectAllAddressByUserId(Page page,@Param("addressUserId") Long userId);

    /**通过id查找此用户的默认地址*/
    @Select("select address_id , address_user_name , address_phone_number , address_city , address_detail , address_user_id , address_isdefault from user_address where address_user_id = #{addressUserId}  and address_isdefault = 1")
    AddressVO selectAddressIsdefault(@Param("addressUserId")Long UserId);
}
